package com.example.jobback.controller.seeker;

import com.example.jobback.aspect.RateLimit;
import com.example.jobback.req.common.page.PageReq;
import com.example.jobback.req.recruiter.seeker.RCrossGetGoodSeekerListReq;
import com.example.jobback.req.seeker.genius.SCrossGetGoodSeekerListReq;
import com.example.jobback.req.seeker.search.SearchJobOrCompanyReq;
import com.example.jobback.resp.manager.employee.page.manager.GetPageManagersResp;
import com.example.jobback.resp.recruiter.seeker.RCrossGetGoodSeekerResp;
import com.example.jobback.resp.seeker.common.SCrossSeekerResp;
import com.example.jobback.resp.seeker.common.page.SCrossGetPageSeekersResp;
import com.example.jobback.resp.seeker.genius.SCrossGetGoodSeekerResp;
import com.example.jobback.resp.seeker.genius.SCrossGetGoodSeekersResp;
import com.example.jobback.resp.seeker.profile.SCrossRecruiterCompanyResp;
import com.example.jobback.resp.seeker.search.SCrossSearchJobOrCompanyResp;
import com.example.jobback.result.Result;
import com.example.jobback.service.seeker.SeekerCommonService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName: SeekerCommonController
 * @Description:求职者-通用控制器
 * @Author: lhb
 * @Date: 2025/6/21
 */
@RestController
@RequestMapping("/seeker/common")
@Tag(name = "求职者-通用控制器",description = "求职者通用服务对应的相关接口")
public class SeekerCommonController {


    private final SeekerCommonService seekerCommonService;

    public SeekerCommonController(SeekerCommonService seekerCommonService) {
        this.seekerCommonService = seekerCommonService;
    }

    @Operation(summary = "获取指定公司招聘者基本信息",description = "跨服务，调用方")
    @PostMapping("/getRecruiterBasicMessage")
    @ApiResponse(description = "返回公司招聘者响应体")
    public Result<SCrossRecruiterCompanyResp> getRecruiterBasicMessage(@Parameter(description = "指定用户的userId", required = true)
                                                                      @RequestParam Long userId){
        return seekerCommonService.getRecruiterBasicMessage(userId);
    }


    @Operation(summary = "获取指定求职者基本信息",description = "跨服务，求职端和招聘端使用")
    @PostMapping("/getSeekerBasicMessage")
    @ApiResponse(description = "返回求职者响应体")
    public Result<SCrossSeekerResp> getSeekerBasicMessage(@Parameter(description = "指定用户的userId", required = true)
                                                                      @RequestParam Long userId){
        return seekerCommonService.getSeekerBasicMessage(userId);
    }


    @Operation(summary = "获取指定求职者基本信息",description = "跨服务，管理员端使用",hidden = true)
    @PostMapping("/getSeekerBasicMessageForAdmin")
    @ApiResponse(description = "返回求职者响应体")
    public Result<SCrossSeekerResp> getSeekerBasicMessageForAdmin(@Parameter(description = "指定用户的userId", required = true)
                                                          @RequestParam Long userId){
        return seekerCommonService.getSeekerBasicMessageForAdmin(userId);
    }


    //公司员工数和岗位数未写，智能推荐未写，需要改变招聘端响应体结构
    @RateLimit
    @Operation(summary = "搜索",description = "搜索岗位或者公司,跨服务，调用方|前端注意：请求体的location和content" +
            ",location为空字符串代表地点不限，智能查询的发生条件就是content为空字符串以及搜索结果为空。" +
            "智能推荐个人期望岗位的元素默认置于期望行业元素的前面。" +
            "目前智能推荐根据个人的期望行业和期望岗位查询，当个人用户没有设置期望岗位或者期望行业时，根据地点随机查询，后续再做优化")
    @PostMapping("/searchJobOrCompany")
    @ApiResponse(description = "返回搜索功能响应体")
    public Result<SCrossSearchJobOrCompanyResp> searchJobOrCompany(@Validated
                                                                       @RequestBody
                                           SearchJobOrCompanyReq req){
        return seekerCommonService.searchJobOrCompany(req);
    }

    @Operation(summary = "获取求职者列表",description = "跨服务被调用方，获取求职者列表",hidden = true)
    @ApiResponse(description = "返回token")
    @PostMapping("/getSeekers")
    public Result<SCrossGetPageSeekersResp> getSeekers(@Validated
                                                           @RequestBody
                                                           PageReq pageReq){
        return seekerCommonService.getSeekers(pageReq);
    }


    @Operation(summary = "获取牛人列表",description = "跨服务调用，被调用方",hidden = true)
    @ApiResponse(description = "无")
    @PostMapping("/getGoodSeekerList")
    public Result<SCrossGetGoodSeekersResp> getGoodSeekerList(@Validated
                                                                   @RequestBody
                                                                   SCrossGetGoodSeekerListReq req){
        return seekerCommonService.getGoodSeekerList(req);
    }

}
